#include <stdio.h>
#include <stdlib.h>
#include <stdio.h>
#include <malloc.h>

struct cell {//��������ṹ�嶨��
    int x;
    struct cell *next;
};

struct cell *build(void) {//�½��������������õĵ������׽���ַ����
    struct cell *head, *tmp, *tail;
    head = tmp = tail = NULL;
    int n;
    scanf("%d", &n);
    if (n == 0)
        return NULL;
    head = (struct cell *) malloc(sizeof(struct cell));
    head->x = n;
    head->next = NULL;
    tail = head;
    while (1) {
        scanf("%d", &n);
        if (n == 0)
            return head;
        tmp = (struct cell *) malloc(sizeof(struct cell));
        tmp->x = n;
        tmp->next = NULL;
        tail->next = tmp;
        tail = tail->next;
    }
    return head;//���ص�����ͷ
}

struct cell *sort(struct cell *head) {//������������head�ǵ������׽��ָ��
    struct cell *p, *p0, *r, *r0, *q;
    p = p0 = r = r0 = q = NULL;
    p = head;
    while (p != NULL) {
        r = head;
        while ((r->x < p->x) && (r != p)) {
            r0 = r;
            r = r->next;
        }
        if (r != p) {
            q = p;
            p0->next = p->next;
            p = p0;
            if (r == head) {
                q->next = head;
                head = q;
            } else {
                q->next = r;
                r0->next = q;
            }
        }
        p0 = p;
        p = p->next;
    }
    return head;
}   /*  sort */


void print(struct cell *head) {//��ӡ����������,head�ǵ������׽��ָ��
    struct cell *p = head;
    int flag = 0;
    while (p != NULL) {
        if (flag)
            printf(" ");
        flag = 1;
        printf("%d", p->x);
        p = p->next;
    }
}

void release(struct cell *head) {//�ͷŵ�����ռ�,head�ǵ������׽��ָ��
    struct cell *p = head, *tmp;
    while (p != NULL) {
        tmp = p;
        p = p->next;
        free(tmp);
    }
}

int main(void) {
    struct cell *head;
    head = build();
    if (head != NULL) {
        head = sort(head);
        print(head);
    } else
        printf("NULL");
    release(head);
    return 0;
}
